home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / editing.doc < prev    next >
Text File  |  1995-03-31  |  2KB  |  38 lines

  1. Program Editing, by Joseph K. Horn 
  2.  
  3. How can one include pre-written Code objects inside 
  4. user-code programs without assembling the entire program? 
  5.  
  6. A very handy way is to use Rick Grevelle's PRG-> and ->PRG routines 
  7. (see IO on this disk) with ROLL and ROLLD. 
  8.  
  9. ---------------------------Example:-------------------------------- 
  10.  
  11. I have a Code object stored in 'JUNK'.  I have a program that looks 
  12. like this: << A B C + JUNK * >>  but I want the program to look 
  13. like this: << A B C + Code * >>.  Here's how to do it: 
  14.  
  15. 1)  << A B C + JUNK * >>   (this is the original program) 
  16. 2)  PRG->   (decomposes program into its objects + count (8)) 
  17. 3)  4 ROLL   (this pulls JUNK down from level 4 to level 1) 
  18. 4)  RCL   (this replaces JUNK with its Code contents) 
  19. 5)  4 ROLLD  (this puts the Code into level 4, where JUNK was) 
  20. 6)  ->PRG   (this recomposes the program into a single object) 
  21. 7)  See << A B C + Code * >> on the stack! 
  22.  
  23. Steps 3 and 5 are done easily by using the interactive stack.  In 
  24. fact, this application is the only time I use the interactive 
  25. stack. 
  26.  
  27. If more than one replacement is to be made, steps 3 through 5 can 
  28. be automated (if you have Donnelly's Tool Library) this way: 
  29. ->LIST 'JUNK' DUP RCL REPLACE OBJ->.  That'll replace every 'JUNK' 
  30. with its contents throughout the whole program.  Global search and 
  31. replace on program objects!  Can't do THAT on most handhelds! 
  32.  
  33. Of course, this method can be used to insert "External"s and 
  34. anything else your heart desires into programs.  You don't ever 
  35. have to assemble the whole thing like we used to do!  Now you can 
  36. write a chunk at a time, verify that each chunk works, and then 
  37. tack the chunks together with ->PRG. 
  38.